package mobi.hami.huapin.util;

import java.text.MessageFormat;

/**
 * 分页Sql
 *
 * @author 阿飞 jijunjian@hami.mobi
 * @date 2018/5/31 21:30
 */
public class CommonPage {
    public static String GetPageSql(String tableName, String primarykey, String field, int pageindex, int pagesize, String order, String where){


        String pageSql = MessageFormat.format("SELECT TOP {0} *  FROM (SELECT ROW_NUMBER() OVER (ORDER BY {1} {2}) AS RowNumber,{3} " +
                "FROM {4} where 1=1 {5} )  as A WHERE RowNumber > {6} *({7}-1) ",
                pagesize, primarykey, order, field, tableName, where, pagesize, pageindex);
        return pageSql;
    }
}
